package Unicart.applogic3;

import Unicart.applogic.NavigationHelper;
import Unicart.model.Item;

public class NavigationHelper3 extends DriverBasedHelper implements NavigationHelper {

  private String baseUrl;
  private String orderAdminUrl;

  public NavigationHelper3(ApplicationManager3 manager) {
	  super(manager.getWebDriver());
    	this.baseUrl = manager.getBaseUrl();
    	this.orderAdminUrl = manager.getOrderAdminUrl();
  }
  
  @Override
  public void openMainPage() {
	  driver.get(baseUrl);
  }

  @Override
  public void openRelativeUrl(String url) {
	  driver.get(baseUrl + url);
  }
  
  @Override
  public void openBasket() {
	  openRelativeUrl("basket");
  }
  
  @Override
  public void addProduct(Item item) {
	  openRelativeUrl("basket/add/"+item.getId());
  }
  
  @Override
  public void addProductWithQuantity(Item item) {
	  openRelativeUrl("basket/add/"+item.getId()+"?quantity="+item.getQuantity());
  }
  
  @Override
  public boolean isBasketIsEmpty() {
	  return pages.basketEmptyPage.waitPageLoaded();
  }
  
  @Override
  public boolean isBasketIsNotEmpty() {
	  return pages.basketPage.waitPageLoaded();
  }

  @Override
  public boolean isStep1Basket() {
	  return pages.basketPage.waitPageLoaded();
  }

 
  @Override
  public void goToStep2() {
	  pages.basketPage.clickGoToStep2Button();
  }

  @Override
  public boolean isStep2ClientData() {
	  return pages.clientDataPage.waitPageLoaded();
  }

  @Override
  public void goToStep3() {
	  pages.clientDataPage.clickGoToStep3Button();	
  }

  @Override
  public boolean isStep3SuccessOrdering() {
	  return pages.successOrderingPage.waitPageLoaded();
  }
  
  @Override
  public void openOrderAdmin() {
	  driver.get(orderAdminUrl);
  }
  
  @Override
  public boolean isOrderAdminPage() {
	  return pages.orderAdminPage.waitPageLoaded();
  }

}
